package Supermercado.Logica;

/*inicio de archivo DateUtil.java */

import java.util.*;

/**Clase para manejo de fechas.
 *
 * @author luciano centis.
 * 
 * no se esta usando por el momento.
 */
public class FechaUtil {
	
    /* entrega la fecha actual:  dd/mm/aaaa, ejemplo: 14/04/2011 */

    public static String getCurrentDate()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);


        int imes = (cal.get(Calendar.MONTH)+1);
        String mes = imes+"";
        if(imes < 10) mes="0"+imes;


        int idia = cal.get(Calendar.DAY_OF_MONTH);
        String dia = idia+"";
        if(idia < 10)
            dia="0"+idia;
        
        return (dia +"/"+mes +"/"+ cal.get(Calendar.YEAR));
//        return cal.get(Calendar.YEAR)+"/"+mes+"/"+dia;
    }

    public static int getYear()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return cal.get(Calendar.YEAR);
    }
    public static int getMonth()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return 1+cal.get(Calendar.MONTH);
    }
    public static int getDay()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return cal.get(Calendar.DAY_OF_MONTH);
    }
    public static int getHour()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return cal.get(Calendar.HOUR);
    }
    public static int getMinute()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return cal.get(Calendar.MINUTE);
    }
    public static int getSecond()
    {
        Date d = new Date();
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        cal.setTime(d);
        return cal.get(Calendar.SECOND);
    }
    
   
    
} /*fin de archivo FechaUtil.java */
